#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int h1,m1,s1,h2,m2,s2;
        int h=0,m=0,s=0;
        cin>>h1>>m1>>s1;
        cin>>h2>>m2>>s2;
        if(s1+s2>=60){
            s=s1+s2-60;
            m++;
        }else{
            s=s1+s2;
        }
        if(m1+m2+m>=60){
            m=m1+m2+m-60;
            h++;
        }else{
            m+=m1+m2;
        }
        h+=h1+h2;
        cout<<h<<" "<<m<<" "<<s<<endl;
    }
    
}